package com.example.coupon.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.example.coupon.entity.CategoryBoundsEntity;
import com.example.coupon.service.CategoryBoundsService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;


/**
 * 商品分类积分设置
 *
 * @author lj
 * @email 980142391@qq.com
 * @date 2023-02-07 20:27:39
 */
@RestController
@RequestMapping("coupon/categorybounds")
public class CategoryBoundsController {
    @Autowired
    private CategoryBoundsService categoryBoundsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("coupon:categorybounds:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = categoryBoundsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("coupon:categorybounds:info")
    public R info(@PathVariable("id") Long id) {
        CategoryBoundsEntity categoryBounds = categoryBoundsService.getById(id);

        return R.ok().put("categoryBounds", categoryBounds);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("coupon:categorybounds:save")
    public R save(@RequestBody CategoryBoundsEntity categoryBounds) {
        categoryBoundsService.save(categoryBounds);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("coupon:categorybounds:update")
    public R update(@RequestBody CategoryBoundsEntity categoryBounds) {
        categoryBoundsService.updateById(categoryBounds);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("coupon:categorybounds:delete")
    public R delete(@RequestBody Long[] ids) {
        categoryBoundsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    public static void main(String[] args) {
        String str = "{\"panels\":[{\"index\":0,\"name\":1,\"height\":80,\"width\":220,\"paperHeader\":0,\"paperFooter\":226.7716535433071,\"printElements\":[{\"options\":{\"left\":186,\"top\":117,\"height\":57,\"width\":145.5,\"field\":\"wareNameTable\",\"fields\":[{\"text\":\"商品名称\",\"field\":\"wareNameTable\"},{\"text\":\"商品编码\",\"field\":\"wareCodeTable\"}],\"right\":330.75,\"bottom\":174.0000114440918,\"vCenter\":258,\"hCenter\":145.5000114440918,\"coordinateSync\":false,\"widthHeightSync\":false,\"lineHeight\":33.75,\"axis\":\"h\",\"columns\":[[{\"width\":72.75,\"title\":\"商品名称\",\"field\":\"wareNameTable\",\"checked\":true,\"columnId\":\"wareNameTable\",\"fixed\":false,\"rowspan\":1,\"colspan\":1,\"align\":\"left\"},{\"width\":72.75,\"title\":\"商品编码\",\"field\":\"wareCodeTable\",\"checked\":true,\"columnId\":\"wareCodeTable\",\"fixed\":false,\"rowspan\":1,\"colspan\":1,\"align\":\"left\"}]]},\"printElementType\":{\"title\":\"商品名称表格\",\"type\":\"table\",\"editable\":true,\"columnDisplayEditable\":true,\"columnDisplayIndexEditable\":true,\"columnTitleEditable\":true,\"columnResizable\":true,\"columnAlignEditable\":true,\"isEnableEditField\":true,\"isEnableContextMenu\":true,\"isEnableInsertRow\":true,\"isEnableDeleteRow\":true,\"isEnableInsertColumn\":true,\"isEnableDeleteColumn\":true,\"isEnableMergeCell\":true}},{\"options\":{\"left\":79.5,\"top\":79.5,\"height\":14,\"width\":120,\"fontSize\":12,\"fontWeight\":\"400\",\"field\":\"customText\",\"hideTitle\":false,\"title\":\"文本\"},\"printElementType\":{\"title\":\"文本\",\"type\":\"text\"}},{\"options\":{\"left\":132,\"top\":55.5,\"height\":32,\"width\":175,\"field\":\"qrcode\",\"textType\":\"qrcode\",\"hideTitle\":true,\"title\":\"二维码\"},\"printElementType\":{\"title\":\"二维码\",\"type\":\"text\"}},{\"options\":{\"left\":75,\"top\":156,\"height\":14,\"width\":9,\"fontSize\":12,\"fontWeight\":\"400\",\"field\":\"vline\",\"hideTitle\":false},\"printElementType\":{\"title\":\"竖线\",\"type\":\"vline\"}},{\"options\":{\"left\":87,\"top\":108,\"height\":14,\"width\":90,\"fontSize\":12,\"fontWeight\":\"400\",\"field\":\"rect\",\"hideTitle\":false},\"printElementType\":{\"title\":\"矩形\",\"type\":\"rect\"}},{\"options\":{\"left\":355.5,\"top\":31.5,\"height\":150,\"width\":150},\"printElementType\":{\"title\":\"图片\",\"type\":\"image\"}}],\"paperNumberLeft\":565,\"paperNumberTop\":204}]}";
        Root root = JSON.parseObject(str, Root.class);

    }

}

class Fields {
    private String text;

    private String field;

    public void setText(String text) {
        this.text = text;
    }

    public String getText() {
        return this.text;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getField() {
        return this.field;
    }
}

class Columns {
    private double width;

    private String title;

    private String field;

    private boolean checked;

    private String columnId;

    private boolean fixed;

    private int rowspan;

    private int colspan;

    private String align;

    public void setWidth(double width) {
        this.width = width;
    }

    public double getWidth() {
        return this.width;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return this.title;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getField() {
        return this.field;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public boolean getChecked() {
        return this.checked;
    }

    public void setColumnId(String columnId) {
        this.columnId = columnId;
    }

    public String getColumnId() {
        return this.columnId;
    }

    public void setFixed(boolean fixed) {
        this.fixed = fixed;
    }

    public boolean getFixed() {
        return this.fixed;
    }

    public void setRowspan(int rowspan) {
        this.rowspan = rowspan;
    }

    public int getRowspan() {
        return this.rowspan;
    }

    public void setColspan(int colspan) {
        this.colspan = colspan;
    }

    public int getColspan() {
        return this.colspan;
    }

    public void setAlign(String align) {
        this.align = align;
    }

    public String getAlign() {
        return this.align;
    }
}

class Options {
    private int left;

    private int top;

    private int height;

    private double width;

    private String field;

    private List<Fields> fields;

    private double right;

    private double bottom;

    private int vCenter;

    private double hCenter;

    private boolean coordinateSync;

    private boolean widthHeightSync;

    private double lineHeight;

    private String axis;

    private List<List<Columns>> columns;

    public void setLeft(int left) {
        this.left = left;
    }

    public int getLeft() {
        return this.left;
    }

    public void setTop(int top) {
        this.top = top;
    }

    public int getTop() {
        return this.top;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getHeight() {
        return this.height;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getWidth() {
        return this.width;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getField() {
        return this.field;
    }

    public void setFields(List<Fields> fields) {
        this.fields = fields;
    }

    public List<Fields> getFields() {
        return this.fields;
    }

    public void setRight(double right) {
        this.right = right;
    }

    public double getRight() {
        return this.right;
    }

    public void setBottom(double bottom) {
        this.bottom = bottom;
    }

    public double getBottom() {
        return this.bottom;
    }

    public void setVCenter(int vCenter) {
        this.vCenter = vCenter;
    }

    public int getVCenter() {
        return this.vCenter;
    }

    public void setHCenter(double hCenter) {
        this.hCenter = hCenter;
    }

    public double getHCenter() {
        return this.hCenter;
    }

    public void setCoordinateSync(boolean coordinateSync) {
        this.coordinateSync = coordinateSync;
    }

    public boolean getCoordinateSync() {
        return this.coordinateSync;
    }

    public void setWidthHeightSync(boolean widthHeightSync) {
        this.widthHeightSync = widthHeightSync;
    }

    public boolean getWidthHeightSync() {
        return this.widthHeightSync;
    }

    public void setLineHeight(double lineHeight) {
        this.lineHeight = lineHeight;
    }

    public double getLineHeight() {
        return this.lineHeight;
    }

    public void setAxis(String axis) {
        this.axis = axis;
    }

    public String getAxis() {
        return this.axis;
    }

    public void setColumns(List<List<Columns>> columns) {
        this.columns = columns;
    }

    public List<List<Columns>> getColumns() {
        return this.columns;
    }
}

class PrintElementType {
    private String title;

    private String type;

    private boolean editable;

    private boolean columnDisplayEditable;

    private boolean columnDisplayIndexEditable;

    private boolean columnTitleEditable;

    private boolean columnResizable;

    private boolean columnAlignEditable;

    private boolean isEnableEditField;

    private boolean isEnableContextMenu;

    private boolean isEnableInsertRow;

    private boolean isEnableDeleteRow;

    private boolean isEnableInsertColumn;

    private boolean isEnableDeleteColumn;

    private boolean isEnableMergeCell;

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return this.title;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getType() {
        return this.type;
    }

    public void setEditable(boolean editable) {
        this.editable = editable;
    }

    public boolean getEditable() {
        return this.editable;
    }

    public void setColumnDisplayEditable(boolean columnDisplayEditable) {
        this.columnDisplayEditable = columnDisplayEditable;
    }

    public boolean getColumnDisplayEditable() {
        return this.columnDisplayEditable;
    }

    public void setColumnDisplayIndexEditable(boolean columnDisplayIndexEditable) {
        this.columnDisplayIndexEditable = columnDisplayIndexEditable;
    }

    public boolean getColumnDisplayIndexEditable() {
        return this.columnDisplayIndexEditable;
    }

    public void setColumnTitleEditable(boolean columnTitleEditable) {
        this.columnTitleEditable = columnTitleEditable;
    }

    public boolean getColumnTitleEditable() {
        return this.columnTitleEditable;
    }

    public void setColumnResizable(boolean columnResizable) {
        this.columnResizable = columnResizable;
    }

    public boolean getColumnResizable() {
        return this.columnResizable;
    }

    public void setColumnAlignEditable(boolean columnAlignEditable) {
        this.columnAlignEditable = columnAlignEditable;
    }

    public boolean getColumnAlignEditable() {
        return this.columnAlignEditable;
    }

    public void setIsEnableEditField(boolean isEnableEditField) {
        this.isEnableEditField = isEnableEditField;
    }

    public boolean getIsEnableEditField() {
        return this.isEnableEditField;
    }

    public void setIsEnableContextMenu(boolean isEnableContextMenu) {
        this.isEnableContextMenu = isEnableContextMenu;
    }

    public boolean getIsEnableContextMenu() {
        return this.isEnableContextMenu;
    }

    public void setIsEnableInsertRow(boolean isEnableInsertRow) {
        this.isEnableInsertRow = isEnableInsertRow;
    }

    public boolean getIsEnableInsertRow() {
        return this.isEnableInsertRow;
    }

    public void setIsEnableDeleteRow(boolean isEnableDeleteRow) {
        this.isEnableDeleteRow = isEnableDeleteRow;
    }

    public boolean getIsEnableDeleteRow() {
        return this.isEnableDeleteRow;
    }

    public void setIsEnableInsertColumn(boolean isEnableInsertColumn) {
        this.isEnableInsertColumn = isEnableInsertColumn;
    }

    public boolean getIsEnableInsertColumn() {
        return this.isEnableInsertColumn;
    }

    public void setIsEnableDeleteColumn(boolean isEnableDeleteColumn) {
        this.isEnableDeleteColumn = isEnableDeleteColumn;
    }

    public boolean getIsEnableDeleteColumn() {
        return this.isEnableDeleteColumn;
    }

    public void setIsEnableMergeCell(boolean isEnableMergeCell) {
        this.isEnableMergeCell = isEnableMergeCell;
    }

    public boolean getIsEnableMergeCell() {
        return this.isEnableMergeCell;
    }
}

class PrintElements {
    private Options options;

    private PrintElementType printElementType;

    public void setOptions(Options options) {
        this.options = options;
    }

    public Options getOptions() {
        return this.options;
    }

    public void setPrintElementType(PrintElementType printElementType) {
        this.printElementType = printElementType;
    }

    public PrintElementType getPrintElementType() {
        return this.printElementType;
    }
}


class Panels {
    private int index;

    private int name;

    private int height;

    private int width;

    private int paperHeader;

    private double paperFooter;

    private List<PrintElements> printElements;

    private int paperNumberLeft;

    private int paperNumberTop;

    public void setIndex(int index) {
        this.index = index;
    }

    public int getIndex() {
        return this.index;
    }

    public void setName(int name) {
        this.name = name;
    }

    public int getName() {
        return this.name;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getHeight() {
        return this.height;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getWidth() {
        return this.width;
    }

    public void setPaperHeader(int paperHeader) {
        this.paperHeader = paperHeader;
    }

    public int getPaperHeader() {
        return this.paperHeader;
    }

    public void setPaperFooter(double paperFooter) {
        this.paperFooter = paperFooter;
    }

    public double getPaperFooter() {
        return this.paperFooter;
    }

    public void setPrintElements(List<PrintElements> printElements) {
        this.printElements = printElements;
    }

    public List<PrintElements> getPrintElements() {
        return this.printElements;
    }

    public void setPaperNumberLeft(int paperNumberLeft) {
        this.paperNumberLeft = paperNumberLeft;
    }

    public int getPaperNumberLeft() {
        return this.paperNumberLeft;
    }

    public void setPaperNumberTop(int paperNumberTop) {
        this.paperNumberTop = paperNumberTop;
    }

    public int getPaperNumberTop() {
        return this.paperNumberTop;
    }
}


class Root {
    private List<Panels> panels;

    public void setPanels(List<Panels> panels) {
        this.panels = panels;
    }

    public List<Panels> getPanels() {
        return this.panels;
    }
}
